<!--
- Author:  LiShibin.
- Date:    2017/7/27 0027.
- File:    pay.
-->
<template>
  <div v-show="show">
    <div class="PopBg z99" style="z-index: 999" id="PopBg"></div>
    <div class="zhifufangshi" style="z-index: 1000;">
      <div @click="closePop" class="guanbi">X</div>
      <ul>
        <li>选择支付方式</li>
        <li :class="{'on': payType == 0}" @click="switchPayType(0)">
          <span><img src="../../assets/images/wx.png" alt=""></span>微信支付
          <i :class="{'icon-xuanzhong1': payType == 0, 'icon-weixuanzhong1': payType != 0}" style="font-size: 20px;" class="iconfont"></i>
        </li>
        <!--<li :class="{'on': payType == 2}" @click="switchPayType(2)">-->
          <!--<span><img src="../../assets/images/yl.png" alt=""></span>银联支付-->
          <!--<i :class="{'icon-xuanzhong1': payType == 2, 'icon-weixuanzhong1': payType != 2}" style="font-size: 20px;" class="iconfont"></i>-->
        <!--</li>-->
        <li :class="{'on': payType == 5}" @click="switchPayType(5)" v-show="$utils.getDeviceType() != 'wx-Android' && $utils.getDeviceType() != 'wx-iPhone'">
          <span><img src="../../assets/images/zfb.png" alt=""></span>支付宝支付
          <i :class="{'icon-xuanzhong1': payType == 5, 'icon-weixuanzhong1': payType != 5}" style="font-size: 20px;" class="iconfont"></i>
        </li>
        <li>
          <div class="zfbtn1">
            <p @click="pay" class="zfbtn1_span1">支付</p>
          </div>
        </li>
      </ul>
    </div>
    <!--<div class="MethodPayment BottomGd bg_fff z100 xd " style="z-index: 1000">-->
      <!--<div class="iconfont icon-close tc" @click="closePop"></div>-->
      <!--<ul>-->
        <!--<li class="pl20">-->
          <!--<i class="iconfont icon-money2 fl mr10"></i><span class="lh100 f26 cr_595757 fl">选择支付方式</span>-->
        <!--</li>-->
        <!--<li :class="{'on': payType == 0}" @click="switchPayType(0)">-->
          <!--<div class="LeftIcon fl"><i class="iconfont icon-wechat cr_18aa04"></i></div>-->
          <!--<div class="fl lh100 f26 cr_595757 ml5"> 微信支付 </div>-->
          <!--<div class="select fr lh100 pr20"><i class="iconfont icon-select"></i></div>-->
        <!--</li>-->
        <!--<li :class="{'on': payType == 1}" @click="switchPayType(1)"  v-show="false">-->
          <!--<div class="LeftIcon fl"><i class="iconfont icon-nonghang" style="color: #009883"></i></div>-->
          <!--<div class="fl lh100 f26 cr_595757 ml5"> 农银快e付 </div>-->
          <!--<div class="select fr lh100 pr20"><i class="iconfont icon-select"></i></div>-->
        <!--</li>-->
        <!--<li :class="{'on': payType == 2}" @click="switchPayType(2)"  v-show="false">-->
          <!--<div class="LeftIcon fl"> <i class="iconfont icon-yinlian cr_18aa04"></i> </div>-->
          <!--<div class="fl lh100 f26 cr_595757 ml5"> 银联支付 </div>-->
          <!--<div class="select fr lh100 pr20"> <i class="iconfont icon-select"></i> </div>-->
        <!--</li>-->
        <!--<li :class="{'on': payType == 3}" @click="switchPayType(3)" v-show="false">-->
          <!--<div class="LeftIcon fl"> <i class="iconfont icon-zhifu2 cr_18aa04"></i> </div>-->
          <!--<div class="fl lh100 f26 cr_595757 ml5"> 第三方的跨行支付 </div>-->
          <!--<div class="select fr lh100 pr20"> <i class="iconfont icon-select"></i> </div>-->
        <!--</li>-->
      <!--</ul>-->
      <!--<button type="button" class="but_2 wauto bg_45a73a mt10" @click="pay">立即支付</button>-->
    <!--</div>-->
  </div>
</template>

<script>
  export default{
    data() {
      return {
        show: true,
        param: {}, // {paySn: '', orderId: '', payType: 0} payType:0 订单支付、1 会员升级续费
        payType: 0, // 0 微信， 1 农行
        closedHandle: function () {
        }
      }
    },
    components: {},
    methods: {
      switchPayType(type) {
        this.payType = type
      },
      switchShowPay(boolValue) {
        this.show = boolValue
      },
      closePop() {
        this.switchShowPay(false)
        this.closedHandle()
      },
      pay() {
        this.switchShowPay(false)
        if (this.payType == 0) {
          this.$native.weixinPay({paySn: this.param.paySn, payType: this.param.payType || 0}).then(data => {
            if (this.param.payType) {
              this.$router.go(-1)
            } else {
              this.$router.push({name: 'order-success', params: {id: this.param.orderId}})
            }
          }).catch(e => {
            this.$toast('支付失败:' + e.msg)
          })
        } else if (this.payType == 1) {
          this.$native.nonghangPay({paySn: this.param.paySn})
        } else if (this.payType == 2) {
          this.$native.yinlianPay({paySn: this.param.paySn})
        } else if (this.payType == 5) {
          this.$native.aliPay({paySn: this.param.paySn, type: this.param.payType || 0, amount: this.param.amount})
        }
      }
    }
  }
</script>

<style>

</style>
